home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Gold Collection
/
Software Vault - The Gold Collection (American Databankers) (1993).ISO
/
cdr05
/
makecard.zip
/
MAKECARD.BAS
next >
Wrap
BASIC Source File
|
1993-07-06
|
3KB
|
91 lines
REM Program to create Cardfile from ASCII text file.
DEFINT A-Z
DIM index$(100), text$(1100), strttxt(100), lentxt(100), numlin(100)
numcard = 1
numtxt = 1
strttxt(1) = 0
null$ = CHR$(0)
crlf$ = CHR$(13) + CHR$(10)
CLS
LINE INPUT "Name of input file? ", filein$
OPEN filein$ FOR INPUT AS #1
LINE INPUT "Name of output file?", fileout$
OPEN fileout$ FOR OUTPUT AS #2
10 LINE INPUT #1, index$(numcard)
' Strip off the asterisk from the index line
20 temp$ = RIGHT$(index$(numcard), LEN(index$(numcard)) - 1)
index$(numcard) = temp$
' If the index line is short, pad it out with blanks
IF LEN(index$(numcard)) < 40 THEN index$(numcard) = index$(numcard) + STRING$(40 - LEN(index$(numcard)), " ")
' Get the text lines
30 LINE INPUT #1, text$(numtxt)
' check to see if another index line
IF LEFT$(text$(numtxt), 1) = "*" THEN GOTO 40
' check to see if there are more than 11 lines
IF numlin(numcard) < 11 THEN 35
PRINT
PRINT "WARNING: The following card has more than 11 lines:"
PRINT "(extra lines ignored)"
PRINT
PRINT index$(numcard)
PRINT
GOTO 30
' increment the character count for all the text for this entry
35 lentxt(numcard) = lentxt(numcard) + LEN(text$(numtxt)) + 2
' increment the number of lines for this entry
numlin(numcard) = numlin(numcard) + 1
IF EOF(1) THEN GOTO 90
numtxt = numtxt + 1
' return for more lines
GOTO 30
40 strttxt(numcard + 1) = strttxt(numcard) + lentxt(numcard) + 4
' calculate the starting position of the text and increment the # of cards
numcard = numcard + 1
index$(numcard) = text$(numtxt)
GOTO 20
'
' write .CRD file
90 PRINT #2, "MGC"; CHR$(numcard); CHR$(0);
PRINT
LINE INPUT "Do you want to have the cards sorted alphabetically? (Y/N, RETURN=Y)", ans$
IF LEFT$(ans$, 1) = "n" OR LEFT$(ans$, 1) = "N" GOTO 99
' simple sort routine
PRINT "Sorting . . ."
FOR i = 1 TO numcard - 1
FOR j = i TO numcard
IF index$(i) < index$(j) GOTO 95
temp$ = index$(j)
index$(j) = index$(i)
index$(i) = temp$
temp = strttxt(j)
strttxt(j) = strttxt(i)
strttxt(i) = temp
95 NEXT j
NEXT i
' end sort routine
99 FOR i = 1 TO numcard
' adjust pointer to start of text based on # of cards
strttxt(i) = strttxt(i) + 5 + numcard * 52
st = strttxt(i)
' convert to least significant byte first format
msb = INT(st / 256)
lsb = st - msb * 256
PRINT #2, STRING$(6, null$); CHR$(lsb); CHR$(msb); null$; null$; null$; index$(i); null$;
NEXT i
k = 0
FOR i = 1 TO numcard
msb = INT(lentxt(i) / 256)
lsb = lentxt(i) - msb * 256
PRINT #2, null$; null$; CHR$(lsb); CHR$(msb);
FOR j = 1 TO numlin(i)
PRINT #2, text$(j + k); crlf$;
NEXT j
k = k + numlin(i)
NEXT i
CLOSE #1
CLOSE #2
SYSTEM